<?php

namespace app\admin\validate\login;

use tmcore\base\BaseValidate;

/**
 * 验证码验证器
 */
class CaptchaValidate extends BaseValidate
{
    protected $rule = [
        'captcha_type'  => 'require|in:blockPuzzle,clickWord',
        'captcha_key'   => 'require',
        'captcha_code'  => 'require',
        'uniqid'  => 'require',
        'code'  => 'require',
    ];

    protected $message = [
        'captcha_type.require'  => '缺少captcha_type参数',
        'captcha_key.require'   => '缺少captcha_key参数',
        'captcha_code.require'  => '缺少captcha_code参数',
        'uniqid.require'  => '缺少uniqid参数',
        'code.require'  => '缺少code参数',
    ];

    /**
     * 创建验证码
     * @return CaptchaValidate
     */
    public function sceneCreate()
    {
        return $this->only(['type']);
    }

    /**
     * 一次验证
     * @return CaptchaValidate
     */
    public function sceneCheck()
    {
        return $this->only(['captcha_type','captcha_key', 'captcha_code']);
    }

    /**
     * 二次验证
     * @return CaptchaValidate
     */
    public function sceneVerification()
    {
        return $this->only(['captcha_type','captcha_key']);
    }

    /**
     * 验证码验证
     * @return CaptchaValidate
     */
    public function sceneCodeVerify()
    {
        return $this->only(['uniqid','code']);
    }
}